package com.alibaba.algo.cooperation.feign.service;

import com.alibaba.algo.cooperation.common.BaseResult;
import com.alibaba.algo.cooperation.feign.config.FeignConfiguration;
import com.alibaba.algo.cooperation.feign.vo.req.*;
import com.alibaba.algo.cooperation.feign.vo.res.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @author Fan.tianpeng
 * @date 2021/5/8 10:33
 */
@FeignClient(url="${feign.userCenterUrl:}", value = "usercenter-service", contextId = "user", configuration = FeignConfiguration.class)
@Api(value = "用户管理", tags = "用户管理")
public interface UserFeignService {

    /**
     * 根据查询条件获取符合条件的用户信息列表
     *
     * @param vo 查询条件
     * @return 用户列表
     */
    @ApiOperation(value = "根据查询条件获取符合条件的用户信息列表")
    @RequestMapping(value = "feignApi/userCenter/user/qryUserList", method = RequestMethod.POST)
    BaseResult<List<UserInfoResVO>> qryUserList(@RequestBody SelectUserListReqVO vo);

    /**
     * 通过用户账号和密码查询用户详情
     *
     * @param vo 用户名
     * @return 用户列表
     */
    @RequestMapping(value = "feignApi/userCenter/user/checkLogin", method = RequestMethod.POST)
    @ApiOperation(value = "通过用户账号和密码查询用户详情")
    BaseResult<LoginUserInfoResVO> checkLogin(@RequestBody SelectUserLoginReqVO vo);

    /**
     * 查询用户详情接口
     *
     * @param vo 用户标识
     * @return 用户详情
     */
    @RequestMapping(value = "feignApi/userCenter/user/qryUserInfo", method = RequestMethod.POST)
    @ApiOperation(value = "查询用户详情接口")
    BaseResult<RpcUserInfoVO> qryUserInfo(@RequestBody SelectUserInfoReqVO vo);

    /**
     * 查询用户标识列表查询对应的用户名映射关系
     *
     * @param vo 用户标识
     * @return 用户映射关系
     */
    @ApiOperation(value = "查询用户标识列表查询对应的用户名映射关系")
    @RequestMapping(value = "feignApi/userCenter/user/qryUserNameMap", method = RequestMethod.POST)
    BaseResult<Map<Long, String>> qryUserNameMap(@RequestBody List<Long> vo);

    /**
     * 根据员工code集合查询员工code和用户id的对应关系map集合
     *
     * @param vo 员工编码
     * @return 用户映射关系
     */
    @ApiOperation(value = "根据员工code集合查询员工code和用户id的对应关系map集合",notes = "查询全量数据,支持范围查询批量调用,批量查询不能超过1000条")
    @RequestMapping(value = "feignApi/userCenter/org/qryUserIdMapByEmployeeCodes", method = RequestMethod.POST)
    BaseResult<Map<String, Long>> qryUserIdMapByEmployeeCodes(@RequestBody List<String> vo);

    @RequestMapping(value = "feignApi/usercenter/user/authByUserReq", method = RequestMethod.POST)
    @ApiOperation(value = "鉴权")
    @Deprecated
    BaseResult authByUser(@RequestBody FeignAuthByUserReqVO authVO);

    @RequestMapping(value = "feignApi/usercenter/user/selectResourceActionListByUser", method = RequestMethod.POST)
    @ApiOperation(value = "获取用户资源")
    BaseResult<Set<FeignSelectResourceActionListVO>> selectResourceActionListByUser(@RequestBody FeignSelectResourceActionListByUserReqVO vo);

    /**
     * 查询用户列表支持租户
     *
     * @param vo 用户标识
     * @return 用户详情
     */
    @ApiOperation(value = "查询用户列表支持租户")
    @RequestMapping(value = "feignApi/userCenter/user/qryUserInfoByUserListOrAppCode", method = RequestMethod.POST)
    BaseResult<List<RpcUserInfoVO>> qryUserInfoByUserListOrAppCode(@RequestBody SelectUserListInfoReqVo vo);


    /**
     * 根据用户查询组织列表
     *
     * @param vo 用户
     * @return
     */
    @ApiOperation(value = "根据用户查询组织列表(默认有效数据)")
    @RequestMapping(value = "feignApi/userCenter/user/orgs", method = RequestMethod.POST)
    BaseResult<List<UserOrgInfoResVO>> getOrgsByUser(@RequestBody GetUserOrgsReqVO vo);

    /**
     * 根据用户查询组织列表(默认包含失效数据)
     *
     * @param vo 用户
     * @return
     */
    @ApiOperation(value = "根据用户查询组织列表(默认全部数据)")
    @RequestMapping(value = "feignApi/userCenter/user/orgsDefaultAll", method = RequestMethod.POST)
    BaseResult<List<UserOrgInfoResVO>> getOrgsByUserDefaultAll(@RequestBody GetUserOrgsReqVO vo);


    /**
     * 通过租户编码分页查询用户信息
     * @param vo 查询条件对象，同后端用户查询页面的条件
     * @return
     */
    @ApiOperation(value = "通过租户编码等条件分页查询用户信息")
    @RequestMapping(value = "feignApi/userCenter/user/selectPageByApp", method = RequestMethod.POST)
    BaseResult selectPageByApp(@RequestBody SelectUserListByAppRequestVO vo);

    /**
     * 通过用户名等条件分页查询用户信息
     * @param vo
     * @return
     */
    @ApiOperation(value = "通过用户名等条件分页查询用户信息")
    @RequestMapping(value = "feignApi/userCenter/user/selectPageEntity", method = RequestMethod.POST)
    BaseResult selectPageEntity(@RequestBody SelectUserListByAppRequestVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/update",method = RequestMethod.POST)
    @ApiOperation(value = "用户更新")
    BaseResult update(@RequestBody @Validated UpdateUserReqVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/resetPassWd",method = RequestMethod.POST)
    @ApiOperation(value = "更新密码")
    BaseResult resetPassWd(@RequestBody @Validated ResetUserPassWordReqVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/checkUserPermissions", method = RequestMethod.POST)
    @ApiOperation(value = "检查用户权限")
    BaseResult checkUserPermissions(@RequestBody CheckUserPermissionsReqVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/getUserBySessionId", method = RequestMethod.POST)
    BaseResult getUserBySessionId(@RequestBody CurrentUserReqVO vo);

    /**
     * 用户全量信息查询
     *
     * @param vo UserAllInfoRequestVO
     * @return UserAllInfoResVo
     */
    @RequestMapping(value = "feignApi/userCenter/user/selectUserAllInfoByUserIdOrUserCode", method = RequestMethod.GET)
    BaseResult selectUserAllInfoByUserIdOrUserCode(@RequestBody UserAllInfoReqVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/selectUserAllInfoByUserIdOrUserCode", method = RequestMethod.POST)
    BaseResult selectUserAllInfoByUserIdOrUserCode1(@RequestBody UserAllInfoReqVO vo);

    @RequestMapping(value = "feignApi/userCenter/user/checkEmpIsNotActive", method = RequestMethod.POST)
    BaseResult checkEmpIsNotActive(@RequestBody CheckEmpReqVO vo);


    @RequestMapping(value = "feignApi/userCenter/user/getRegisteredUserCount", method = RequestMethod.GET)
    BaseResult<Integer> getRegisteredUserCount();

}
